package org.example.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;
import org.example.dto.ShanjiaZhxg;
import org.example.dto.Shanjiaimagexg;
import org.example.entity.Shanjia;
import org.example.entity.Shanpin;
import org.example.result.Pages;

@Mapper
public interface Shanjiamapper {



    /**
     * 商家查询
     * @param shanjia
     * @return
     */
    Shanjia chaxun(Shanjia shanjia);

    /**
     * 商家新增
     * @param shanjia
     */
    @Insert("INSERT INTO shanjia (username, name, password,shouji,shefenzhen,create_time,update_time,yingye,image)\n" +
            "VALUES\n" +
            "(#{username}, #{name}, #{password}, #{shouji},#{shefenzhen},#{createTime},#{updateTime},#{yingye},#{image})")
    void inst(Shanjia shanjia);

    /**
     * 忘记密码
     * @param shanjia
     */
    @Update("UPDATE shanjia\n" +
            "SET password = #{password}\n" +
            "WHERE  username= #{username};")
    void wangji(Shanjia shanjia);

    /**
     * 修改
     * @param shanjia
     */
    @Update("UPDATE shanjia\n" +
            "SET yingye = !#{yingye}\n" +
            "WHERE  username= #{username};")
    void xg(Shanjia shanjia);

    /**
     * 账户修改
     * @param shanjiaZhxg
     */
    void zhxg(ShanjiaZhxg shanjiaZhxg);

    /**
     * 修改image
     *
     *
     */
    @Update("UPDATE shanjia\n" +
            "SET image=#{newname}\n" +
            "WHERE  username= #{username};")
    void xgimage(Shanjiaimagexg shanjiaimagexg);


    /**
     * 注销账户
     * @param username
     */
    @Delete("DELETE FROM shanjia\n" +
            "WHERE username=#{username}")
    void delete(String username);

    /**
     * 查询
     * @param yonghu
     */
    @Select("select password from shanjia where username=#{yonghu}")
    String cx(String yonghu);
}
